/*
 * SEGUNDA ENTREGA DEL PROYECTO DE BASES DE DATOS "BIBLIOTECA DIGITAL"
 * 
 * Integrantes:
 * Gamboa Edwin Ricardo Cód: 0926631 plan: 2711
 * Portilla Cortes Maria Cristina Cód: 0844113 plan: 3743 
 * Rosero Rosero Luis Alberto Cód: 0943740 plan:3743
 * 
 */

/*
 * GUIPrincipal.java
 *
 * Created on 3/05/2011, 08:48:44 PM
 */
package gui;
import controlador.*;
import javax.swing.*;
/**
 *
 * @author Gamboa Family
 */
public class GUIPrincipal extends javax.swing.JFrame {
    String codigo="Inivitado";
    Boolean logeado=false;
    /** Creates new form GUIPrincipal */
    public GUIPrincipal() {
        initComponents();
        setExtendedState(MAXIMIZED_BOTH);
        setTitle("Bibblioteca Digital EISC - Invitado ");
//        BMiPerfil.setEnabled(false);
//        BGestionarMaterial.setEnabled(false);
//        BOtrasGestiones.setEnabled(false);
//        BMiPerfil.setEnabled(false);
//        BGestionarUsuarios.setEnabled(false);
//        BReportes.setEnabled(false);

        BMiPerfil.setVisible(false);
        BGestionarMaterial.setVisible(false);
        BOtrasGestiones.setVisible(false);
        BMiPerfil.setVisible(false);
        BGestionarUsuarios.setVisible(false);
        BReportes.setVisible(false);
        jPanelNotificaciones.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jPanelFunciones = new javax.swing.JPanel();
        jPanelNotificaciones = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTANotificaciones = new javax.swing.JTextArea();
        jPanelIngreso = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTFLogin = new javax.swing.JTextField();
        jBIngresar = new javax.swing.JButton();
        jPasswordField1 = new javax.swing.JPasswordField();
        BConsultaGeneral = new javax.swing.JButton();
        BConsultaAvanzada = new javax.swing.JButton();
        BMiPerfil = new javax.swing.JButton();
        BReportes = new javax.swing.JButton();
        BOtrasGestiones = new javax.swing.JButton();
        BGestionarMaterial = new javax.swing.JButton();
        BGestionarUsuarios = new javax.swing.JButton();
        jPanelCentral = new javax.swing.JPanel();
        jLabel57 = new javax.swing.JLabel();
        jBCerrarSesion = new javax.swing.JButton();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(53, 53, 53)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(164, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(91, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("tab1", jPanel1);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(255, 255, 255));

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));

        jPanelFunciones.setBackground(new java.awt.Color(242, 242, 242));
        jPanelFunciones.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(235, 30, 30)));

        jPanelNotificaciones.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Notificaciones", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 14), new java.awt.Color(235, 30, 30))); // NOI18N

        jTANotificaciones.setColumns(20);
        jTANotificaciones.setEditable(false);
        jTANotificaciones.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        jTANotificaciones.setLineWrap(true);
        jTANotificaciones.setRows(5);
        jTANotificaciones.setWrapStyleWord(true);
        jScrollPane1.setViewportView(jTANotificaciones);

        javax.swing.GroupLayout jPanelNotificacionesLayout = new javax.swing.GroupLayout(jPanelNotificaciones);
        jPanelNotificaciones.setLayout(jPanelNotificacionesLayout);
        jPanelNotificacionesLayout.setHorizontalGroup(
            jPanelNotificacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
        );
        jPanelNotificacionesLayout.setVerticalGroup(
            jPanelNotificacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelNotificacionesLayout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanelIngreso.setBackground(new java.awt.Color(255, 255, 255));
        jPanelIngreso.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Usuarios registrado", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 14), new java.awt.Color(235, 30, 30))); // NOI18N

        jLabel3.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(130, 134, 135));
        jLabel3.setText("Login");

        jLabel4.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(130, 134, 135));
        jLabel4.setText("Password");

        jTFLogin.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        jTFLogin.setForeground(new java.awt.Color(0, 0, 0));
        jTFLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTFLoginActionPerformed(evt);
            }
        });

        jBIngresar.setBackground(new java.awt.Color(255, 255, 255));
        jBIngresar.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jBIngresar.setForeground(new java.awt.Color(235, 30, 30));
        jBIngresar.setText("Ingresar");
        jBIngresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBIngresarActionPerformed(evt);
            }
        });

        jPasswordField1.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        jPasswordField1.setForeground(new java.awt.Color(0, 0, 0));
        jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordField1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelIngresoLayout = new javax.swing.GroupLayout(jPanelIngreso);
        jPanelIngreso.setLayout(jPanelIngresoLayout);
        jPanelIngresoLayout.setHorizontalGroup(
            jPanelIngresoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelIngresoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelIngresoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelIngresoLayout.createSequentialGroup()
                        .addGroup(jPanelIngresoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3))
                        .addGap(22, 22, 22)
                        .addGroup(jPanelIngresoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
                            .addComponent(jTFLogin, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelIngresoLayout.createSequentialGroup()
                        .addComponent(jBIngresar, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(23, 23, 23))))
        );
        jPanelIngresoLayout.setVerticalGroup(
            jPanelIngresoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelIngresoLayout.createSequentialGroup()
                .addGroup(jPanelIngresoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelIngresoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addComponent(jBIngresar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, Short.MAX_VALUE)
                .addContainerGap())
        );

        BConsultaGeneral.setBackground(new java.awt.Color(255, 255, 255));
        BConsultaGeneral.setFont(new java.awt.Font("Verdana", 1, 14));
        BConsultaGeneral.setForeground(new java.awt.Color(235, 30, 30));
        BConsultaGeneral.setMnemonic('G');
        BConsultaGeneral.setText("Consulta General");
        BConsultaGeneral.setToolTipText("Pulse para buscar Materiales en la biblioteca.");
        BConsultaGeneral.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BConsultaGeneralActionPerformed(evt);
            }
        });

        BConsultaAvanzada.setBackground(new java.awt.Color(255, 255, 255));
        BConsultaAvanzada.setFont(new java.awt.Font("Verdana", 1, 14));
        BConsultaAvanzada.setForeground(new java.awt.Color(235, 30, 30));
        BConsultaAvanzada.setMnemonic('A');
        BConsultaAvanzada.setText("Consulta Avanzada");
        BConsultaAvanzada.setToolTipText("Pulse para buscar Materiales de forma avanzada en la biblioteca.");
        BConsultaAvanzada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BConsultaAvanzadaActionPerformed(evt);
            }
        });

        BMiPerfil.setBackground(new java.awt.Color(255, 255, 255));
        BMiPerfil.setFont(new java.awt.Font("Verdana", 1, 14));
        BMiPerfil.setForeground(new java.awt.Color(235, 30, 30));
        BMiPerfil.setText("Mi Perfil");
        BMiPerfil.setToolTipText("Pulse para ver y modifcar su información personal.");
        BMiPerfil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BMiPerfilActionPerformed(evt);
            }
        });

        BReportes.setBackground(new java.awt.Color(255, 255, 255));
        BReportes.setFont(new java.awt.Font("Verdana", 1, 14));
        BReportes.setForeground(new java.awt.Color(235, 30, 30));
        BReportes.setMnemonic('R');
        BReportes.setText("Reportes");
        BReportes.setToolTipText("Pulse para generar reportes con información estadística de la Biblioteca.");
        BReportes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BReportesActionPerformed(evt);
            }
        });

        BOtrasGestiones.setBackground(new java.awt.Color(255, 255, 255));
        BOtrasGestiones.setFont(new java.awt.Font("Verdana", 1, 14));
        BOtrasGestiones.setForeground(new java.awt.Color(235, 30, 30));
        BOtrasGestiones.setMnemonic('O');
        BOtrasGestiones.setText("Otras Gestiones");
        BOtrasGestiones.setToolTipText("Pulse para registrar, modificar y desactivar areas, autores, tipos de material y palabras clave.");
        BOtrasGestiones.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BOtrasGestionesActionPerformed(evt);
            }
        });

        BGestionarMaterial.setBackground(new java.awt.Color(255, 255, 255));
        BGestionarMaterial.setFont(new java.awt.Font("Verdana", 1, 14));
        BGestionarMaterial.setForeground(new java.awt.Color(235, 30, 30));
        BGestionarMaterial.setMnemonic('M');
        BGestionarMaterial.setText("Gestionar Material");
        BGestionarMaterial.setToolTipText("Pulse para catalogar, modificar y descativar Materiales.");
        BGestionarMaterial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BGestionarMaterialActionPerformed(evt);
            }
        });

        BGestionarUsuarios.setBackground(new java.awt.Color(255, 255, 255));
        BGestionarUsuarios.setFont(new java.awt.Font("Verdana", 1, 14));
        BGestionarUsuarios.setForeground(new java.awt.Color(235, 30, 30));
        BGestionarUsuarios.setMnemonic('U');
        BGestionarUsuarios.setText("Gestionar Usuarios");
        BGestionarUsuarios.setToolTipText("Pulse para registrar, modificar perfiles o desactivar usuarios.");
        BGestionarUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BGestionarUsuariosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelFuncionesLayout = new javax.swing.GroupLayout(jPanelFunciones);
        jPanelFunciones.setLayout(jPanelFuncionesLayout);
        jPanelFuncionesLayout.setHorizontalGroup(
            jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelFuncionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BReportes, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                    .addComponent(BGestionarUsuarios, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                    .addComponent(BMiPerfil, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                    .addComponent(BConsultaAvanzada, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                    .addComponent(BConsultaGeneral, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                    .addComponent(jPanelIngreso, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanelNotificaciones, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BGestionarMaterial, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                    .addComponent(BOtrasGestiones, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelFuncionesLayout.setVerticalGroup(
            jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFuncionesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BConsultaGeneral)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BConsultaAvanzada)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BMiPerfil)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BGestionarUsuarios)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BReportes)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BGestionarMaterial)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BOtrasGestiones)
                .addGap(18, 18, 18)
                .addComponent(jPanelIngreso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelNotificaciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanelCentral.setBackground(new java.awt.Color(255, 255, 255));
        jPanelCentral.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(235, 30, 30)));

        jLabel57.setBackground(new java.awt.Color(255, 255, 255));
        jLabel57.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/imagen.JPG"))); // NOI18N

        jBCerrarSesion.setBackground(new java.awt.Color(255, 255, 255));
        jBCerrarSesion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/cerrarSesion.png"))); // NOI18N
        jBCerrarSesion.setToolTipText("Pulse para cerrar sesión.");
        jBCerrarSesion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCerrarSesionActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jPanelFunciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanelCentral, javax.swing.GroupLayout.DEFAULT_SIZE, 896, Short.MAX_VALUE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel57)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBCerrarSesion, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jBCerrarSesion, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel57, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jPanelCentral, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE)
                        .addContainerGap())
                    .addComponent(jPanelFunciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BMiPerfilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BMiPerfilActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelMiperfil panelCentral = new PanelMiperfil(codigo);
        panelCentral.llenarListasDias();
        panelCentral.llenarFormulario();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(true, true, true, true, false);
        this.validate();
        this.repaint();
    }//GEN-LAST:event_BMiPerfilActionPerformed

    private void jBCerrarSesionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCerrarSesionActionPerformed
        // TODO add your handling code here:
        int respuesta = JOptionPane.showConfirmDialog(this, "¿Esta seguro "
                + "que desea Cerrar la Sesión?");
        if(respuesta == JOptionPane.YES_OPTION){
             jPanelFunciones.add(jPanelIngreso);
             BMiPerfil.setVisible(false);
             BGestionarUsuarios.setVisible(false);
             BMiPerfil.setVisible(false);
             BGestionarMaterial.setVisible(false);
             BOtrasGestiones.setVisible(false);
             jPanelNotificaciones.setVisible(false);
             jPanelCentral.removeAll();
             logeado=false;
             consultaGeneral();
        }
}//GEN-LAST:event_jBCerrarSesionActionPerformed

    private void jTFLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFLoginActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jTFLoginActionPerformed

    private void jBIngresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBIngresarActionPerformed
        // TODO add your handling code here:
        ControladorUsuario control_usuario = new ControladorUsuario();
        boolean completo = true;
        String mensaje = "Se presentaron los siguientes errores:";
        if(jTFLogin.getText().equals("")){
            completo = false;
            mensaje += "-> El campo login está vacío." + "\n";
        }
        if(jPasswordField1.getText().equals("")){
            completo = false;
            mensaje += "-> El campo password está vacío." + "\n";
        }
        if(control_usuario.usuarioIdentificado(jTFLogin.getText(),
                jPasswordField1.getText()) == 2){
            completo = false;
            mensaje += "-> El password es incorrecto." + "\n";
            jPasswordField1.setText("");
        }
        if(control_usuario.usuarioIdentificado(jTFLogin.getText(),
                jPasswordField1.getText()) == 0){
            completo = false;
            mensaje += "-> El login ingresado no esta registrado." + "\n";
            jTFLogin.setText("");
            jPasswordField1.setText("");
        }
        if(!completo)
            JOptionPane.showMessageDialog(this, mensaje, "Error de Ingreso",
                    JOptionPane.ERROR_MESSAGE);
        if(completo){
            String tipoUsuario = control_usuario.tipoUsuario(jTFLogin.getText());
            codigo = control_usuario.getCodigo(jTFLogin.getText());
            String titulo = control_usuario.retornarUsuarioPorCodigo(codigo).mostrarmeEnPantalla();
            System.out.println("Codigo consultado" + codigo);
            jTFLogin.setText("");
            jPasswordField1.setText("");
            jPanelFunciones.remove(jPanelIngreso);
            jPanelNotificaciones.setVisible(true);            
            logeado=true;
            consultaGeneral();
            if(tipoUsuario.equals("0")){
                BMiPerfil.setVisible(true);
                BGestionarUsuarios.setVisible(true);
                BReportes.setVisible(true);                
                this.setCodigo(codigo);
                this.llenarAreaNotificaiones();
                this.setTitle("Bibblioteca Digital EISC - Administrador: " + titulo);
                this.validate();
                this.repaint();

            }
            if(tipoUsuario.equals("1")){
                BMiPerfil.setVisible(true);
                BGestionarMaterial.setVisible(true);
                BOtrasGestiones.setVisible(true);
                this.setCodigo(codigo);
                this.setTitle("Bibblioteca Digital EISC - Catalogador: " + titulo);
                this.llenarAreaNotificaiones();
                this.validate();
                this.repaint();
            }
            if(tipoUsuario.equals("2")){
                GUIUsuarioNormal guiUsuario = new GUIUsuarioNormal();
                guiUsuario.setCodigo(codigo);
                guiUsuario.llenarAreaNotificaiones();
                guiUsuario.setExtendedState(MAXIMIZED_BOTH);
                guiUsuario.setTitle("Bibblioteca Digital EISC - Usuario Normal: " + titulo);
                this.llenarAreaNotificaiones();
                guiUsuario.setVisible(true);
            }
//            dispose();
//            jTFLogin.setText("");
//            jPasswordField1.setText("");
        }
}//GEN-LAST:event_jBIngresarActionPerformed

    private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jPasswordField1ActionPerformed

    private void BConsultaAvanzadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BConsultaAvanzadaActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelConsultaAvanzada panelCentral = new PanelConsultaAvanzada();
        if(logeado)panelCentral.habilitarDescarga();
        panelCentral.setUsuarioQueConsulta(codigo);
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(true, true, true, false, true);
        this.validate();
        this.repaint();
        System.out.println("Panel consulta general");
}//GEN-LAST:event_BConsultaAvanzadaActionPerformed

    private void BConsultaGeneralActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BConsultaGeneralActionPerformed
        // TODO add your handling code here:
        consultaGeneral();
}//GEN-LAST:event_BConsultaGeneralActionPerformed

    private void BOtrasGestionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BOtrasGestionesActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelOtrasGestiones panelCentral = new PanelOtrasGestiones();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(true, false, true, true, true);
        this.validate();
        this.repaint();
        System.out.println("Panel otras gestiones");
}//GEN-LAST:event_BOtrasGestionesActionPerformed

    private void BGestionarMaterialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BGestionarMaterialActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelGestionMaterial panelCentral = new PanelGestionMaterial();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(false, true, true, true, true);
        this.validate();
        this.repaint();
        System.out.println("Panel gestion material");
}//GEN-LAST:event_BGestionarMaterialActionPerformed

    private void BReportesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BReportesActionPerformed
        this.validate();
        this.repaint();
        PanelReportes panelCentral = new PanelReportes();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(false, true, true, true, true);
        this.validate();
        this.repaint();
        System.out.println("Panel gestion material");
}//GEN-LAST:event_BReportesActionPerformed

    private void BGestionarUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BGestionarUsuariosActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelGestionUsuarios panelCentral = new PanelGestionUsuarios();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(false, true, true, true, true);
        this.validate();
        this.repaint();
        System.out.println("Panel gestion material");
}//GEN-LAST:event_BGestionarUsuariosActionPerformed

    public void activarBotones(Boolean gm, Boolean og, Boolean cg, 
            Boolean ca, Boolean mp){
        BGestionarMaterial.setEnabled(gm);
        BOtrasGestiones.setEnabled(og);
        BConsultaGeneral.setEnabled(cg);
        BConsultaAvanzada.setEnabled(ca);
        BMiPerfil.setEnabled(mp);
    }
    
    public void setCodigo(String codigo){
        this.codigo = codigo;
    }
    
    public void llenarAreaNotificaiones(){
        ControladorUsuario control = new ControladorUsuario();
        jTANotificaciones.setText(control.cargarNotificaciones(codigo));
    }

    public void consultaGeneral(){
        this.validate();
        this.repaint();
        PanelConsultaGeneral panelCentral = new PanelConsultaGeneral();
        if(logeado) panelCentral.habilitarDescarga();
        panelCentral.setUsuarioQueConsulta(codigo);
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(true, true, false, true, true);
        this.validate();
        this.repaint();
        System.out.println("Panel consulta general");
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new GUIPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BConsultaAvanzada;
    private javax.swing.JButton BConsultaGeneral;
    private javax.swing.JButton BGestionarMaterial;
    private javax.swing.JButton BGestionarUsuarios;
    private javax.swing.JButton BMiPerfil;
    private javax.swing.JButton BOtrasGestiones;
    private javax.swing.JButton BReportes;
    private javax.swing.JButton jBCerrarSesion;
    private javax.swing.JButton jBIngresar;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanelCentral;
    private javax.swing.JPanel jPanelFunciones;
    private javax.swing.JPanel jPanelIngreso;
    private javax.swing.JPanel jPanelNotificaciones;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTANotificaciones;
    private javax.swing.JTextField jTFLogin;
    private javax.swing.JTabbedPane jTabbedPane1;
    // End of variables declaration//GEN-END:variables
}
